#include "orb.hpp"
#include <glog/logging.h>

namespace slam
{

bool ORB::Init(OrbAttr& attr)
{
    attr_ = attr;
    orbDetector_ = cv::ORB::create(attr_.nfeatures, attr_.scaleFactor, 
        attr_.nlevels, attr_.edgeThreshold, attr_.firstLevel, attr_.wta_k,
        attr_.scoreType, attr_.patchSize, attr_.fastThreshold);
    // todo, check orbDetector
    LOG(INFO) << "orb feature init success";
    return true;
}

bool ORB::Extract(cv::Mat image)
{
    src_ = image;
    orbDetector_->detectAndCompute(image, cv::Mat(), keyPointVec_, outputArray_);
    LOG(INFO) << "orb extract success";
    return true;
}

bool ORB::Clean()
{
    LOG(INFO) << "orb clean success";
    return true;
}

std::vector<cv::KeyPoint> ORB::KeyPoint(void) const
{
    return keyPointVec_;
}

void ORB::DrawKeyPoints(void)
{
    cv::drawKeypoints(src_, keyPointVec_, src_);
    cv::imshow("orb_keypoint_image", src_);
}

} // namespace slam